package com.crm.service.impl;

import com.crm.common.utils.DateUtils;
import com.crm.common.utils.StringUtils;
import com.crm.domain.vo.CourseVo;
import com.crm.mapper.CourseMapper;
import com.crm.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;



@Component
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper courseMapper;
    //查询课程信息
    @Override
    public List<CourseVo> selectCourseList(CourseVo courseVo) {
        return courseMapper.selectCourseList(courseVo);
    }
    //根据id查询课程信息
    @Override
    public CourseVo getCourseById(Long id) {
        return courseMapper.getCourseById(id);
    }

    //添加课程信息
    //添加课程信息
    @Override
    public int insertCourse(CourseVo courseVo) {

        courseVo.setCreateTime(DateUtils.getNowDate());
        //获取一个八位的随机码放到code里
        courseVo.setCode(StringUtils.getRandom(8));
        return courseMapper.insertCourse(courseVo);

    }

    @Override
    public int updateCourse(CourseVo courseVo) {
        return courseMapper.updateCourse(courseVo);
    }

    @Override
    public int deleteCourseByIds(Long[] ids) {
        return courseMapper.deleteCourseByIds(ids);
    }

    @Override
    public boolean checkCluePhoneExis(String phone) {
        return false;
    }
}
